<?php
class View_Administration_Server_List extends View_Administration_Server
{
	public function buildContent()
	{
		$link		= $this->request->get( 'link' );
		$servers	= Logic_Server::getServerList();
		$words		= $this->words['server']['listServers'];

		$list		= array();
		foreach( $servers as $server )
		{
			$projects	= Logic_Project::getProjectsFromServer( $server['server_id'], 2 );
			foreach( $projects as $projectId => $projectData )
			{
				$title		= $this->html->Acronym( $projectData['title'], $projectData['description'] );
				$projects[$projectId]	= $this->html->Link( "?link=manageProjects&projectId=".$projectId, $title );
			}
			$server['projects']	= implode( "<br/>", array_values( $projects ) );
			$server['link']		= $link;
			$server['created']	= $server['created'] ? date( "d.m.Y H:i", $server['created'] ) : "";
			$server['modified']	= $server['modified'] ? date( "d.m.Y H:i", $server['modified'] ) : "";
			$list[]	= $this->loadTemplate( 'administration.server.item', $server );
		}
		$ui	= array(
			'words'		=> $words,
			'list'		=> implode( "\n", $list ),
			'buttonAdd'	=> $this->html->LinkButton(
				self::getUrl( array( 'action' => 'add' ) ),
				$words['buttonAdd'],
				'but add'
			)
		);
		return $this->loadTemplate( 'administration.server.list', $ui );
	}
}
?>